import { getCustomerList, getCustomerTypeValueList, getQualityTypeList } from "@/api/print/mesProdOthercode";

export const customerDislog = {
    data() {
        return {
            customerDialogVisible: false, //表格弹框隐藏显示
            getCustomerList, // 获取弹框数据接口
            customerFooter: true, // 是否需要底部按钮默认true
            customerSearchConfig: {
                inline: true,
                isShowResetBtn: true,
                formDesc: {
                    customerCode: {
                        type: "input",
                        label: $i18n.t("mesOtherCodePrinting.customerCode"), //"编码",
                        attrs: {
                            clearable: true,
                        },
                        layout: 6,
                    },
                    customerName: {
                        type: "input",
                        label: $i18n.t("mesOtherCodePrinting.customerName"), //"名称",
                        attrs: {
                            clearable: true,
                        },
                        layout: 6,
                    },
                },
            },
            customerColumn: [
                {
                    type: "selection",
                },
                {
                    type: "index",
                    align: "center",
                    label: $i18n.t("common.order"),
                    width: "60",
                },
                {
                    prop: "customerCode",
                    label: $i18n.t("mesOtherCodePrinting.customerCode"),
                    minWidth: "100",
                    showOverflowTooltip: true,
                },
                {
                    prop: "customerName",
                    label: $i18n.t("mesOtherCodePrinting.customerName"),
                    minWidth: "100",
                    showOverflowTooltip: true,
                },
                {
                    prop: "address",
                    label: $i18n.t("mesOtherCodePrinting.address"),
                    width: 250,
                    showOverflowTooltip: true,
                },
                {
                    prop: "contacts",
                    label: $i18n.t("mesOtherCodePrinting.contacts"),
                    width: 100,
                    showOverflowTooltip: true,
                },
                {
                    prop: "mobilePhone",
                    label: $i18n.t("mesOtherCodePrinting.mobilePhone"),
                    width: 120,
                    showOverflowTooltip: true,
                },
                {
                    prop: "telephone",
                    label: $i18n.t("mesOtherCodePrinting.telephone"),
                    width: 130,
                    showOverflowTooltip: true,
                },
                {
                    prop: "customerTypeValue",
                    label: $i18n.t("mesOtherCodePrinting.customerTypeValue"),
                    width: 120,
                    showOverflowTooltip: true,
                    optionProp: {
                        value: "value",
                        label: "description",
                    },
                    option: async (data) => {
                        const list = await getCustomerTypeValueList();
                        return list.data.result;
                    },
                },
                {
                    prop: "qualityType",
                    label: $i18n.t("mesOtherCodePrinting.qualityType"),
                    optionProp: {
                        value: "value",
                        label: "description",
                    },
                    option: async (data) => {
                        const list = await getQualityTypeList();
                        return list.data.result;
                    },
                    minWidth: 100,
                },
            ],
        };
    },
    methods: {
        // 弹框表格，双击表格，或者点击确定 返回选中数据
        getSelectCustomer(data) {
            // 调试完成记得删除控制台打印
            console.log("选中数据--客商--", data);
            // 这里可以自定义返回字段信息

            this.key = new Date().getTime()
            // 第一个入参为当前表单绑定的对象，第二个入参为要修改的字段名，第三个入参为选中数据中相应信息
            this.$set(this.createData, "customerCode", data[0].customerCode);
            this.$set(this.createData, "customerName", data[0].customerName);

        },
    },
};
